package com.zm.devmag.util;

import com.sun.jna.Library;
import com.sun.jna.Native;


import java.text.SimpleDateFormat;
import java.util.Date;





public class TscPrint {
	public interface TscLibDll extends Library {
        TscLibDll INSTANCE = (TscLibDll) Native.loadLibrary("TSCLIB", TscLibDll.class);
        int about();
        int openport(String pirnterName);
        int closeport();
        int sendcommand(String printerCommand);
        int setup(String width, String height, String speed, String density, String sensor, String vertical, String offset);
        int downloadpcx(String filename, String image_name);
        int barcode(String x, String y, String type, String height, String readable, String rotation, String narrow, String wide, String code);
        int printerfont(String x, String y, String fonttype, String rotation, String xmul, String ymul, String text);
        int clearbuffer();
        int printlabel(String set, String copy);
        int formfeed();
        int nobackfeed();
        int windowsfont(int x, int y, int fontheight, int rotation, int fontstyle, int fontunderline, String szFaceName, String content);
    }

    public static void PrintByTSC(String qrCode,String title,String dno) {
    	
        System.setProperty("jna.encoding", "GBK");// 支持中文
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String time = df.format(new Date());
        //String qrCode = "PD102011";
        //TscLibDll.INSTANCE.about();
        TscLibDll.INSTANCE.openport("TSC TTP-244 Plus");
        System.out.println("1111111111111111111222222222222");
       // TscLibDll.INSTANCE.openport("\\\\192.168.6.90\\TSC TTP-244 Plus");
        System.out.println("1111111111111111111222222222222");
        //TscLibDll.INSTANCE.downloadpcx("C:\\UL.PCX", "UL.PCX");
        TscLibDll.INSTANCE.setup("99.5","70","5","8","0","2","0");
        TscLibDll.INSTANCE.clearbuffer();
        //TscLibDll.INSTANCE.sendcommand("PUTPCX 550,10,\"UL.PCX\"");
        String command = "QRCODE 300,250,Q,8,A,0,M2,S7,\"" + qrCode+"\""; //打印二维码的参数和内容
        TscLibDll.INSTANCE.sendcommand(command); //传送指令
        TscLibDll.INSTANCE.windowsfont(260, 100, 36, 0, 0, 0, "arial", title);
        TscLibDll.INSTANCE.windowsfont(260, 150, 36, 0, 0, 0, "arial", dno);
        TscLibDll.INSTANCE.windowsfont(450, 200, 32, 0, 0, 0, "arial", time);
        TscLibDll.INSTANCE.printlabel("1", "1");
        TscLibDll.INSTANCE.closeport();
    }
}
